package com.teng.mylibrary.ui.activity

import android.os.Bundle
import android.view.View
import androidx.lifecycle.ViewModelProvider
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.teng.mylibrary.R
import com.teng.mylibrary.base.BaseActivity
import com.teng.mylibrary.base.BaseViewModel
import com.teng.mylibrary.databinding.ActivityPhotoViewBinding
import com.teng.mylibrary.ui.adapter.PhotoViewAdapter

@Route(path = "/library/PhotoViewActivity")
class PhotoViewActivity : BaseActivity<ActivityPhotoViewBinding, BaseViewModel>() {

    @JvmField
    @Autowired(name = "index")
    var index: String? = ""

    var photos: ArrayList<String>? = null

    private val adapter by lazy { PhotoViewAdapter(this, photos!!) }

    override fun initContentView(savedInstanceState: Bundle?): Int {
        return R.layout.activity_photo_view
    }

    override fun initViewModel(): BaseViewModel {
        return ViewModelProvider(this).get(BaseViewModel::class.java)
    }

    override fun initView() {
        window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
        supportActionBar?.hide()
        photos = intent.getStringArrayListExtra("photos")
        binding.viewPager.adapter = adapter
        if (!index.isNullOrEmpty()) {
            binding.viewPager.setCurrentItem(index!!.toInt(), false)
        }
    }

    override fun initData() {
    }
}